﻿import com.gamepackage.tilemap.*;

class com.gamepackage.tilemap.layer.Sprite implements com.gamepackage.tilemap.Moveable
{
	private var x: Number, y: Number;
	
	private var linkageId: String;
	
	private var parent: MovieClip;
	private var timeline: MovieClip;
	private var depth: Number;
	
	private var layer: Layer;

	function Sprite( layer: Layer )
	{
		this.layer = layer;
	}
	
	function attach( linkageId: String, parent: MovieClip, depth: Number ): Void
	{
		timeline = ( this.parent = parent ).attachMovie( this.linkageId = linkageId , depth.toString() , depth , { _x: x - layer.getX(), _x: y - layer.getY() } );
	}
	
	function remove( Void ): Void
	{
		timeline.removeMovieClip();
	}
	
	function moveTo( x: Number, y: Number ): Void
	{
		timeline._x = ( this.x = x ) - layer.getX();
		timeline._y = ( this.y = y ) - layer.getY();
	}
	
	function getTimeline( Void ): MovieClip
	{
		return timeline;
	}
	
	function getX( Void ): Number
	{
		return x;
	}
	function getY( Void ): Number
	{
		return y;
	}
}